package com.hmkj.core.po.operate;


import lombok.Data;
import lombok.EqualsAndHashCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.hmkj.common.baseMapper.GenericPo;
import java.util.function.Consumer;
import javax.persistence.Table;
import javax.persistence.Transient;

import  java.util.Map;
import  java.util.Date;
import  java.util.HashMap;
import  com.alibaba.fastjson.annotation.JSONField;


/**
 * 代理商表实体信息<br>
 *
 * @author bin
 * @date   2017-11-07 02:41:04
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "代理商表")
@Table(name = "biz_agent")
public class Agent extends GenericPo<Integer> {

    public static final String TABLE_NAME = "biz_agent";


    /**代理商名称**/
    @ApiModelProperty(value = "代理商名称")
    private String name;
    /**代理商ID**/
    @ApiModelProperty(value = "代理商ID")
    private String code;
    /**代理商协议显示名称**/
    @ApiModelProperty(value = "代理商协议显示名称")
    private String fullName;
    /**代理商域名**/
    @ApiModelProperty(value = "代理商域名")
    private String domain;
    @ApiModelProperty(value = "短信签名")
    private String smsSign;
    /**1,正常:T1;2,冻结:T2;**/
    @ApiModelProperty(value = "1,正常:T1;2,冻结:T2;")
    private Integer status;
    @Transient
    private String statusFormatter ;
    public String getStatusFormatter() {
        if(null == statusFormatter || "".equals(statusFormatter)){
            return STATUS.getValue(getStatus());
        }
        return this.statusFormatter;
    }
    public void setStatusFormatter(String statusFormatter) {
        this.statusFormatter=statusFormatter;
    }
    /**1,正常:T1<br>2,冻结:T2<br>**/
    public enum STATUS {

        /**1,正常:T1**/
        T1("正常",1),

        /**2,冻结:T2**/
        T2("冻结",2);

        public final int code;
        public final String value;
        private static Map<Integer, String> map = new HashMap<Integer, String>();

        private STATUS(String value, int code) {
            this.code = code;
            this.value = value;
        }

        public static String getValue(Integer code) {
            if (null == code) {
                return null;
            }
            for (STATUS status : STATUS.values()) {
                if (status.code == code) {
                    return status.value;
                }
            }
            return null;
        }

        public static Integer getCode(String value) {
            if (null == value  || "".equals(value)) {
                return null;
            }
            for (STATUS status : STATUS.values()) {
                if (status.value.equals(value)) {
                    return status.code;
                }
            }
            return null;
        }

        public static  Map<Integer, String> getEnumMap() {
            if(map.size() == 0){
                for (STATUS status : STATUS.values()) {
                    map.put(status.code,status.value);
                }
            }
            return map;
        }
    }


    public Agent(){}

    public Agent(Consumer<Agent> consumer){
        consumer.accept(this);
    }
}

